package com.ding.easycontroller.utils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class PluginUtils {
/*

    private static final HashMap<String, Plugin> PLUGINS = new HashMap<>();

    public static List<Plugin> getPlugins() {
        return new ArrayList<>(PLUGINS.values());
    }


    //初始化系统自带插件
    public static void initSystemPlugins(List<Plugin> plugins){
        addPlugins(plugins);
    }

    //从文件系统初始化插件 目前暂不处理
    public static void initPluginsFromFIle(String path) {
*//*
        File pF = new File(path);

        if (!pF.exists()) {
            return;
        }

*//*

        List<Plugin> plugins = new ArrayList<>();

   *//*     File[] files = pF.listFiles();
        if (files == null) {
            return;
        }

        List<String> jfs = new ArrayList<>();

        for (File file : files) {
            if (file.getName().endsWith(".jar")) {
                jfs.tryAdd(file.getAbsolutePath());
            }
        }

        //
        ClassLoadUtils.loadClasspath(jfs);
*//*
        PluginUtils.addPlugins(plugins);

    }*/

/*
    private static void addPlugins(List<Plugin> plugins) {
        for (Plugin plugin : plugins) {
            if (plugin.getName() == null) {
                throw new RuntimeException("无效名称");
            }
            Plugin old = PLUGINS.getById(plugin.getName());
            if (old != null) {
                throw new RuntimeException(plugin.getName() + "插件存在冲突:" + old.getClass() + "  " + plugin.getClass());
            }
            PLUGINS.put(plugin.getName(), plugin);
        }
    }*/


}
